<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>
			Mont Blanc Foot F7 - Editar Equipo: <?php echo $team_nombre;?>
		</title>

		<?php $this -> load -> view('head_view');?>

		<style type="text/css">
			#dialog-text {
				font-size: 62.5%;
			}
			/*demo page css*/
			#dialog_link {
				padding: .4em 1em .4em 20px;
				text-decoration: none;
				position: relative;
			}
			.add-players td {
				width: 400px;
			}
			#dialog_link span.ui-icon {
				margin: 0 5px 0 0;
				position: absolute;
				left: .2em;
				top: 50%;
				margin-top: -8px;
			}
		</style>

		<script language="javascript" type="text/javascript">
function test() {
alert("Hola test");
//$.post("test.php", { name: "John", time: "2pm" } );
}

$( function() {

var team_id=<?php echo $team_id;?>;

	$("input:submit").button({
            icons: {
                primary: "ui-icon-locked",
            },
            text: false
        });
	$('#loading-gif').hide();
	// Dialog
	$('#dialog').dialog({
		autoOpen: false,
		width: 600,
		buttons: {
			"Ok": function() {
				$(this).dialog("close");
			},
			"Cancel": function() {
				$(this).dialog("close");
			}
		}
	});

	// Dialog Link
	$('#dialog_link').click( function() {
		//$('#dialog').dialog('open');

		var players = $("select[name=non-players] :selected").map( function(i,n) {
			return $(n).val();
		}).get();
		$(this).removeClass('ui-state-hover');
		//alert(db);
		$('#loading-gif').show();
		$.post("/index.php/teams/saveplayers", {
			'team_id' : team_id,
			'team_players[]': players
		}, function(response) {
			//$("#dbdisplay").html(response);
			var $dialog = $('<div></div>')
			.html('Jugadores Agregados!')
			.dialog({
				autoOpen: false,
				title: 'Agregar Jugadores',
				buttons: {
					"Ok": function() {

						$(this).dialog("close");
						$('#loading-gif').hide();
					}
				}

			});
			$("#team-players-div").load("/index.php/teams/playerListingAJAX/"+team_id);
			$("#non-players-div").load("/index.php/teams/nonPlayerListingAJAX/"+team_id);
			$dialog.dialog('open');
			//alert("Jugadores Agregados!")
		});
		//$.post("test.php", {
		//	name: "John",
		//	time: "2pm"
		//}, function(data) {
		//	alert("Data Loaded: " + data);
		//});
		return false;
	});
	//hover states on the static widgets
	$('#dialog_link, ul#icons li').hover( function() {
		$(this).addClass('ui-state-hover');
	}, function() {
		$(this).removeClass('ui-state-hover');
	}
	);

	$("#team-players-div").load("/index.php/teams/playerListingAJAX/"+team_id);
	$("#non-players-div").load("/index.php/teams/nonPlayerListingAJAX/"+team_id);

	$('#to2').click( function() {

		var str = "";

		//alert($('#team_players').val());
		//$("#select[name=non-players] :selected").each(function(){
		$("select[name=non-players] :selected").each( function() {
			str +=$(this).val();
			//$(this).appendTo('#teamplayers');
		});
		alert('str = ' + str);

		//alert('Handler for .click() called.');
		var str = "";
		//alert($('#to2 :selected').text());
		//alert(str);
	});
	//$.configureBoxes();

	});
		</script>
	</head>
	<body id="page1">
		<div id="line-hor-players">
		</div>
		<div id="main-bg-top">
			<div id="main-bg-bot">
				<div id="main">
					<!-- header -->
					<div id="header">
						<?php $this -> load -> view('league_header');?>
					</div>
					<!-- content -->
					<div id="content">
						<!-- script -->

						<div id="indent">
							<!-- scroller news -->
							<div id="team-edit-form">
								<h2>Registro de Equipos</h2>
								<br/>
								<p>
									Favor de completar los siguientes campos:
								</p>
								<?php echo form_open('teams/save');?>
								<p>
									<label for="fname">
										Nombre del equipo:
									</label>
									<br />
									<?php echo form_hidden('team_id', $team_id);?>
									<?php echo form_input($team_name);?>
								</p>
								<p>
									<label for="category">
										Categor&iacute;a del Equipo:
									</label>
									<br />
									<?php echo form_dropdown('category_id', $options, $category);?>
								</p>
								<p>
									<?php echo form_submit('submit', 'Guardar Cambios');?>
								</p>
								<?php echo form_close();?>
								<?php ?>

								<!--

								TABLE FOR PLAYERS NOT IN THE TEAM

								-->
								<div id="player-selection-div">
									<!-- ui-dialog -->
									<div id="dialog" title="Dialog Title">
										<p id="dialog-text">
											Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
										</p>
									</div>

									<?php echo form_open('teams/saveplayers');?>
									<center>
										<h3>Agregar Jugadores</h3>
									</center>
									<div id = "team-players-div">

									</div>
									<table class="add-players">
										<tr>
											<td>
											<div id="non-players-div">
											</div>
											<br />
											<a href="#" id="dialog_link" class="ui-state-default ui-corner-all">
											<span class="ui-icon ui-icon-circle-plus"></span>Agregar Jugadores
											</a>
											<img src="/images/prettyphoto/dark_rounded/loader.gif" style="margin-left: 30px;" id="loading-gif">
											</td>
										</tr>
									</table>
								</div>
								<input type="hidden" value="<?php echo $team_id;?>" id="team_id" name="team_id">
								<?php //echo form_submit('submit', 'Guardar Cambios');?>
								<?php //echo form_button('submit', 'Guardar Cambios', $js);?>
								<?php echo form_close();?>
							</div>
							<div class="wrapper">
								<div id="column-left">

									<p class="news">
										<!--<strong class="news">Modulo Editar Equipos Jugadores.</strong> -->
									</p>
									<!-- Latest players added to league -->
									<!-- Team Administration -->
								</div>
							</div>
						</div>
					</div>
					<!-- footer -->
					<div id="footer">
						<?php $this -> load -> view('league_footer');?>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			$( function() {
				$("#faded").faded({
					speed: 500,
					autopagination: false,
					autoplay: 4000,
					autorestart: true,
					crossfade: true
				});
			});
		</script>
	</body>
</html>
